<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>{$title}-<tp:sitename /></title>
    <link rel="shortcut icon" href="__PUBLIC__/images/favicon.ico" type="image/x-icon" /> 
    <link rel="stylesheet" href="__PUBLIC__/css/style_version1.css" type="text/css" />
    <link rel="stylesheet" href="__PUBLIC__/css/base.css">
    <script src="__PUBLIC__/js/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
	function changeVcode(obj){
		$("#VCode").attr("src",'<tp:vcodeurl />'+ '#'+Math.random());
		return false;
	}
	</script>
</head> 
<body> 

<include file="Public:header" />

<div class="wrap">
    <div class="pop-title clearfix">
        <a class="a_underline" href="{:U('Public/login')}">登录</a>    
        <div class="pop_name">
            会员注册
        </div>

    </div>
    <form onsubmit="return false">
        <div class="pop-content accountPage">
            
            <div class="form_item">
                <div class="item_tip">邮箱</div>
                <input type="text" tabindex="1" value="" data-type="email" name="email" class="form_input" id="email" onfocus="focusInputLoginArea($(this))" onblur="blurInputLoginArea($(this))" autocomplete="off">
                <span class="error">不能为空</span>	
                <i class="icon-loginright"></i>
            </div>
            <div class="form_item">
                <div class="item_tip">用户名</div>
                <input type="text" tabindex="2" value="" name="username" data-type="username" data-minlength="5" class="form_input" id="username" onfocus="focusInputLoginArea($(this))" onblur="blurInputLoginArea($(this))" autocomplete="off">
                <span class="error">不能为空</span>
                <i class="icon-loginright"></i>
                <span class="grey">允许用中英文、数字、下划线，提交后不可修改</span>
            </div>
            <div class="form_item">
                <div class="item_tip">密码</div>
                <input type="password" tabindex="3" name="password" id="pwd" data-minlength="6" data-maxlength="20" class="form_input" onfocus="focusInputLoginArea($(this))" onblur="blurInputLoginArea($(this))" autocomplete="off">
                <span class="error">不能为空</span>
                <span class="grey">6 - 20位</span>
                <i class="icon-loginright"></i>
            </div>			
            <div class="form_item">
                <div class="item_tip">确认密码</div>
                <input type="password" tabindex="4" name="rpassword" data-equal="#pwd" data-equal-error="两次输入的密码不一致" class="form_input" id="pwd2" onfocus="focusInputLoginArea($(this))" onblur="blurInputLoginArea($(this))" autocomplete="off">
                <span class="error">不能为空</span>
                <i class="icon-loginright"></i>
            </div>
            
            <if condition="C('CFG_VERIFY_REGISTER') eq 1">
            <div class="form_item">
                <div class="item_tip">验证码</div>
                <input type="text" tabindex="5" name="vcode" id="code" class="small_input" onfocus="focusInputLoginArea($(this))" onblur="blurInputLoginArea($(this))" autocomplete="off" /><img src="<tp:vcodeurl />" id="VCode" style="vertical-align:middle; cursor:pointer;" height="35" onClick="javascript:changeVcode(this);" />
                <span class="error">不能为空</span>
                <i class="icon-loginright"></i>
            </div>
            </if>
            
            <div class="form_item" style="margin:30px  0 0">
                <input type="submit" tabindex="7" value="注&nbsp;&nbsp;册" class="btn_reg btn" id="btn_reg" onclick="subReg()">
            </div>

        </div>
    </form>
</div>

<script type="text/javascript">
    function subReg() {
        blurInputLoginArea($("#username"), 1);
        blurInputLoginArea($("#email"), 1);
        blurInputLoginArea($("#pwd"));
        blurInputLoginArea($("#pwd2"));
		blurInputLoginArea($("#code"), 1);
		
		var username = $("#username").val();
		var email = $("#email").val();
		var password = $("#pwd").val();
		var rpassword = $("#pwd2").val();
		var vcode = $("#code").val();
		
        var i = 0;
        $(".error").each(function() {
            if ($(this).css("display") == 'inline') {
                i++;
            }
        })

        if (i == 0) {
            var obj = $("#btn_reg");
            obj.addClass('disabled').val('注册中...');
            $.post("{:U('Ajax/regsave')}", {username: username, password: password, rpassword: rpassword, email: email, vcode: vcode}, function(data) {
                if (data.error != '') {
                    alert(data.error);
                } else {
                    showSuccessTip(data.tip);
                    var url = "<tp:siteurl />";
                    setTimeout("goUrl('" + url + "')", 1500);
                }
                obj.removeClass('disabled').val('注册');
            }, "json")
        }
    }
</script>

<include file="Public:footer" />

</body>
</html>
